package com.leco.demo.spring;

import com.leco.demo.spring.beans.Bean1;
import com.leco.demo.spring.processor.MyBeanFactoryPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

import java.util.Arrays;

/**
 * @author greg
 * @version 2022/10/23
 * 探索拓展BeanFactoryPostProcessor的方法
 **/
public class BeanFactoryPostProcessorExpandDemo {
    public static void main(String[] args) {
        method1();
//        method2();
    }

    private static void method2() {
        MyApplicationContext context = new MyApplicationContext();
        context.registerBean("bean1", Bean1.class);
        context.refresh();
        System.out.println(Arrays.toString(context.getBeanDefinitionNames()));
    }

    private static void method1() {
        GenericApplicationContext context = new GenericApplicationContext();
        context.registerBean("bean1", Bean1.class);
        context.registerBean(MyBeanFactoryPostProcessor.class);
        context.refresh();
        System.out.println(Arrays.toString(context.getBeanDefinitionNames()));
    }
}
